<?php 
class menu extends CI_model{

	function menu_list(){
		$query = "SELECT m.id_menu, ml.judul_menu, m.sort_order FROM menu m INNER JOIN menu_language ml ON m.id_menu=ml.id_menu WHERE ml.id_language = 1 AND m.id_menu_sub = 0 ORDER BY m.sort_order ASC";
		$sql = $this->db->query($query);
		return $sql->result();
	}

	function get_all(){
		$query = "SELECT m.id_menu, ml.judul_menu FROM menu m INNER JOIN menu_language ml ON m.id_menu=ml.id_menu WHERE ml.id_language = 1 AND m.id_menu_sub = 0 ";
		$q = $this->db->query($query);
		
		$var = array();
		foreach($q->result() as $r){
			$var[$r->id_menu] = $r->judul_menu;
		}
		/*return $q->result_array();*/
		return $var;
	}

	function get_child($id_menu){
		$query = "SELECT m.id_menu, ml.judul_menu, m.sort_order FROM menu m INNER JOIN menu_language ml ON m.id_menu=ml.id_menu WHERE ml.id_language = 1 AND m.id_menu_sub = $id_menu";
		$q = $this->db->query($query);
		
		/*return $q->result_array();*/
		return $q->result();
	}

	function get_menu($db, $where){
		$this->db->where($where);
		$q = $this->db->get($db);

		return $q->result_array();
	}

	function get_list($db){
		$this->db->where('id_language', '1');
		$q = $this->db->get($db);
		$id = 'id_page';
		$data = array();
		foreach($q->result() as $row){
			$data[$row->$id] = $row->judul_page;
		}
		return $data;
	}

	function get_list_modul($db){
		$q = $this->db->get($db);
		$id = 'id_'.$db;
		$data = array();
		foreach($q->result() as $row){
			$data[$row->$id] = $row->judul_modul;
		}
		return $data;
	}
}

?>